import { ChessType } from '../types/enums'
import './ChessC.css'

interface ChessCProps {
	type: ChessType
	handleClick?: () => void
}

export function ChessC({ type, handleClick }: ChessCProps) {
	let chess = null
	if (type === ChessType.red) {
		chess = <div className="red chess-item"></div>
	} else if (type === ChessType.black) {
		chess = <div className="black chess-item"></div>
	}
	return (
		<div
			className="chess"
			onClick={() => {
				if (type === ChessType.none) {
					handleClick && handleClick()
				}
			}}
		>
			{chess}
		</div>
	)
}
